import React, { PureComponent } from 'react';
import { withRemove } from './index';
import VideoUpload from '@/components/Modular/VideoUpload';

@withRemove
class VideoComponent extends PureComponent {
  state = {
    src: this.props.data.mediaUrl,
  };

  handleChange = url => {
    const { data } = { ...this.props };
    data.mediaUrl = url;
    this.props.onChange(data);
    this.setState({ src: url });
  };

  render() {
    const { src } = this.state;
    return <VideoUpload src={src} onChange={this.handleChange} />;
  }
}

export default VideoComponent;
